/**
 * @file
 * @author  Tsin Smith <tsin.creator@gmail.com>
 *
 */

#ifndef __TSIN_UTIL_SET_HPP__
#define __TSIN_UTIL_SET_HPP__

#include <tsin/util/common.hpp>

namespace tsin {

        /**
         * @class Set
         * @ingroup util
         * @brief An interface for pointer containers with an internal
         *        linear iterator.
         */
        template <class T>
        class Set
        {
        public:
                virtual ~Set() {}

                /**
                 * Get actual number of bullets in the set.
                 *
                 * @return Actual number of bullets.
                 */
                virtual int size() = 0;

                /**
                 * Insert a bullet to the set.
                 *
                 * @param ptr The bullet to be inserted.
                 * @return True if the bullet is really inserted. False if the set is already full.
                 */
                virtual bool insert(T ptr) = 0;

                /**
                 * Remove the bullet pointed to by the internal iterator.
                 *
                 * @return The bullet removed. Note that the bullet is not freed.
                 */
                virtual T remove() = 0;

                /**
                 * Whether internal iterator points at the beginning.
                 *
                 * @return True if internal iterator points at the beginning.
                 */
                virtual bool atBegin() = 0;

                /**
                 * Whether internal iterator points at the end.
                 *
                 * @return True if internal iterator points at the end.
                 */
                virtual bool atEnd() = 0;

                /**
                 * Move the internal iterator to the beginning.
                 */
                virtual void toBegin() = 0;

                /**
                 * Move the internal iterator to the end.
                 */
                virtual void toEnd() = 0;

                /**
                 * Move the internal iterator backward.
                 * Keep the iterator unmodified if it is at the beginning or end.
                 */
                virtual void prev() = 0;

                /**
                 * Move the internal iterator forward.
                 * Keep the iterator unmodified if it is at the beginning or end.
                 */
                virtual void next() = 0;

                /**
                 * Get the current bullet pointed to by the internal iterator.
                 *
                 * @return The bullet pointed to by internal iterator.
                 */
                virtual T get() = 0;
        };

}

#endif /* __TSIN_UTIL_SET_HPP__ */
